package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsRegionMapper;
import com.qf.mapper.DtsRoleMapper;
import com.qf.pojo.DtsRegion;
import com.qf.service.DtsRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author 邢式瑞
 * @version 1.0
 * @project E-commercebackGroundManagementSystem
 * @date 2022/9/23 20:50
 */
@Service
public class DtsRegionServiceImpl implements DtsRegionService {
    @Autowired
    private DtsRegionMapper dtsRegionMapper;
    @Override
    public Page<DtsRegion> selectPage(Integer page, Integer limit, String sort, String order, String name, Integer code) {
        Page<DtsRegion> dtsRegionPage = new Page<>(page, limit);
        QueryWrapper<DtsRegion> dtsRegionQueryWrapper = new QueryWrapper<>();
        dtsRegionQueryWrapper.orderBy(!StringUtils.isEmpty(sort),"asc".equalsIgnoreCase(order),sort).like(!StringUtils.isEmpty(name),"name",name).eq(code!=null,"code",code);
        return dtsRegionMapper.selectPage(dtsRegionPage,dtsRegionQueryWrapper);
    }
}
